package com.plian.system.service.pf.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.plian.Tools.CollectionUtil;
import com.plian.system.entity.pf.EnterpriseAnnuityDetail;
import com.plian.system.mapper.pf.EnterpriseAnnuityDetailMapper;
import com.plian.system.mybatis.base.BaseServiceImpl;
import com.plian.system.service.pf.IEnterpriseAnnuityDetailService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Description: TODO
 * @Author: Take-off
 * @Date: 2023/3/13 10:01 AM
 * @Param
 * @return
 * @Version: 1.0
 **/
@Slf4j
@Service
@AllArgsConstructor
public class EnterpriseAnnuityDetailServiceImpl extends BaseServiceImpl<EnterpriseAnnuityDetailMapper,EnterpriseAnnuityDetail> implements IEnterpriseAnnuityDetailService {

    @Override
    public boolean deleteByParentId(List<Long> ids) {
        LambdaQueryWrapper<EnterpriseAnnuityDetail> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(EnterpriseAnnuityDetail::getBaseId, ids);
        List<EnterpriseAnnuityDetail> details = list(queryWrapper);
        if (CollectionUtil.isNotEmpty(details)){
            return deleteLogic(details.stream().map(EnterpriseAnnuityDetail::getId).collect(Collectors.toList()));
        }
        return true;
    }


}
